from django.shortcuts import render
from django.http import HttpResponse


# Create your views here.
def fun_shax_page(request):
    return render(request, 'app03/html01_01.html')


def fun_shax(request):
    # 获取前端输入的工资
    v_request_get = request.GET
    v_shax_str = v_request_get.get('shax')
    v_user_name = v_request_get.get('user_name')
    v_user_sheng = v_request_get.get('user_sheng')
    v_user_company=v_request_get.get('user_company')
    v_shax = int(v_shax_str)
    # 计算个人所得税
    v_result = 0
    v_temp = v_shax - 5000
    if v_temp <= 0:
        v_result = 0
    elif v_temp <= 3000:
        v_result = v_temp * 0.03
    elif v_temp <= 12000 and v_temp > 3000:
        v_result = v_temp * 0.1
    elif v_temp <= 25000 and v_temp > 12000:
        v_result = v_temp * 0.2
    elif v_temp <= 35000 and v_temp > 25000:
        v_result = v_temp * 0.25
    elif v_temp <= 55000 and v_temp > 35000:
        v_result = v_temp * 0.3
    elif v_temp <= 80000 and v_temp > 55000:
        v_result = v_temp * 0.35
    else:
        v_result = v_temp * 0.45
        pass

    v_people=People(v_user_name,v_user_sheng,v_user_company,v_result)

    return render(request,'app03/html01_01_result.html',locals())


class  People:
    def __init__(self,user_name,user_sheng,user_company,result):
        self.user_name=user_name
        self.user_sheng=user_sheng
        self.user_company=user_company
        self.result = result
    pass